package com.siyougame.business.controller.admin.inspect;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.*;

import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import com.siyougame.common.pojo.PageResult;
import com.siyougame.common.pojo.CommonResult;
import static com.siyougame.common.pojo.CommonResult.success;

import com.siyougame.common.utils.ExcelUtils;

import com.siyougame.common.annotation.OperateLog;
import static com.siyougame.common.enums.OperateTypeEnum.*;

import com.siyougame.business.controller.admin.inspect.vo.*;
import com.siyougame.business.dal.dataobject.inspect.InspectDO;
import com.siyougame.business.convert.inspect.InspectConvert;
import com.siyougame.business.service.inspect.InspectService;

@Api(tags = "管理后台 - 检查记录")
@RestController
@RequestMapping("/openapi/business/inspect")
@Validated
public class InspectController {

    @Resource
    private InspectService inspectService;

    //@PostMapping("/create")
    //@ApiOperation("创建检查记录")
    //@PreAuthorize("@ss.hasPermi('business:inspect:create')")
    //public CommonResult<Long> createInspect(@Valid @RequestBody InspectCreateReqVO createReqVO) {
    //    return success(inspectService.createInspect(createReqVO));
    //}

    @PutMapping("/update")
    @ApiOperation("更新检查记录")
    public CommonResult<Boolean> updateInspect(@Valid @RequestBody InspectUpdateReqVO updateReqVO) {
        inspectService.updateInspect(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @ApiOperation("删除检查记录")
    @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)

    public CommonResult<Boolean> deleteInspect(@RequestParam("id") Long id) {
        inspectService.deleteInspect(id);
        return success(true);
    }

    @GetMapping("/get")
    @ApiOperation("获得检查记录")
    @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)

    public CommonResult<InspectRespVO> getInspect(@RequestParam("id") Long id) {
        InspectDO inspect = inspectService.getInspect(id);
        return success(InspectConvert.INSTANCE.convert(inspect));
    }

    //@GetMapping("/list")
    //@ApiOperation("获得检查记录列表")
    //@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
    //@PreAuthorize("@ss.hasPermi('business:inspect:query')")
    //public CommonResult<List<InspectRespVO>> getInspectList(@RequestParam("ids") Collection<Long> ids) {
    //    List<InspectDO> list = inspectService.getInspectList(ids);
    //    return success(InspectConvert.INSTANCE.convertList(list));
    //}

    @GetMapping("/page")
    @ApiOperation("获得检查记录分页")
    public CommonResult<PageResult<InspectRespVO>> getInspectPage(@Valid InspectPageReqVO pageVO) {
        PageResult<InspectDO> pageResult = inspectService.getInspectPage(pageVO);
        return success(InspectConvert.INSTANCE.convertPage(pageResult));
    }

    //@GetMapping("/export-excel")
    //@ApiOperation("导出检查记录 Excel")
    //@PreAuthorize("@ss.hasPermi('business:inspect:export')")
    //@OperateLog(type = EXPORT)
    //public void exportInspectExcel(@Valid InspectExportReqVO exportReqVO,
    //          HttpServletResponse response) throws IOException {
    //    List<InspectDO> list = inspectService.getInspectList(exportReqVO);
    //    // 导出 Excel
    //    List<InspectExcelVO> datas = InspectConvert.INSTANCE.convertList02(list);
    //    ExcelUtils.write(response, "检查记录.xls", "数据", InspectExcelVO.class, datas);
    //}

}
